package com.jetpackframework.basemd;

import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.frameworkx.layout.activity_drawer_layout;
import com.jetpackframework.ContextUtil;
import com.jetpackframework.R;
import com.jetpackframework.R2;
import com.jetpackframework.base.BaseActivity;

/**
 * 抽屉式布局
 */

public abstract class BaseDrawerLayoutActivity extends BaseActivity<activity_drawer_layout> {
    @Override
    protected void initEventListener() {
        mBinding = getViewBind(R2.layout.activity_drawer_layout);
        View view = LayoutInflater.from(ContextUtil.get()).inflate(mBinding.getLayoutId(), null, false);
        setContentView(view);
        mBinding.bindView(view);

        Fragment mainFragment = getMainFragment();
        Fragment menuFragment = getMenuFragment();
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.frame_main,mainFragment,"mainFragment");
        transaction.replace(R.id.frame_menu,menuFragment,"menuFragment");
        transaction.commit();

        //打开左边的菜单
//        mBinding.dl_layout.openDrawer(Gravity.LEFT);

    }

    protected abstract Fragment getMenuFragment();

    protected abstract Fragment getMainFragment();
}
